package com.tudouji.project.copy.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.copy.domain.MultipartConfig;
import com.tudouji.project.copy.service.IMultipartConfigService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 交易设置Controller
 * 
 * @author wf
 * @date 2021-01-07
 */
@RestController
@RequestMapping("/copy/config")
public class MultipartConfigController extends BaseController
{
    @Autowired
    private IMultipartConfigService multipartConfigService;

    /**
     * 查询交易设置列表
     */
    @PreAuthorize("@ss.hasPermi('copy:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(MultipartConfig multipartConfig)
    {
        startPage();
        List<MultipartConfig> list = multipartConfigService.selectMultipartConfigList(multipartConfig);
        return getDataTable(list);
    }

    /**
     * 导出交易设置列表
     */
    @PreAuthorize("@ss.hasPermi('copy:config:export')")
    @Log(title = "交易设置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MultipartConfig multipartConfig)
    {
        List<MultipartConfig> list = multipartConfigService.selectMultipartConfigList(multipartConfig);
        ExcelUtil<MultipartConfig> util = new ExcelUtil<MultipartConfig>(MultipartConfig.class);
        return util.exportExcel(list, "config");
    }

    /**
     * 获取交易设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('copy:config:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(multipartConfigService.selectMultipartConfigById(id));
    }

    /**
     * 新增交易设置
     */
    @PreAuthorize("@ss.hasPermi('copy:config:add')")
    @Log(title = "交易设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MultipartConfig multipartConfig)
    {
        return toAjax(multipartConfigService.insertMultipartConfig(multipartConfig));
    }

    /**
     * 修改交易设置
     */
    @PreAuthorize("@ss.hasPermi('copy:config:edit')")
    @Log(title = "交易设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MultipartConfig multipartConfig)
    {
        return toAjax(multipartConfigService.updateMultipartConfig(multipartConfig));
    }

    /**
     * 删除交易设置
     */
    @PreAuthorize("@ss.hasPermi('copy:config:remove')")
    @Log(title = "交易设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(multipartConfigService.deleteMultipartConfigByIds(ids));
    }
}
